package com.pur.zsms.pmsnmanage.user.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Query;

import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.pur.zsms.common.dao.GenericDao;
import com.pur.zsms.common.dao.JpaTemplate;
import com.pur.zsms.common.exception.GenericException;
import com.pur.zsms.common.support.PageController;
import com.pur.zsms.common.support.PaginationSupport;
import com.pur.zsms.common.util.PubFun;
import com.pur.zsms.foodmanage.food.dao.IFoodDao;
import com.pur.zsms.foodmanage.food.po.FoodMaterPo;
import com.pur.zsms.foodmanage.food.po.FoodPo;
import com.pur.zsms.foodmanage.food.vo.FoodMaterVo;
import com.pur.zsms.foodmanage.food.vo.FoodVo;
import com.pur.zsms.ordercustommanage.po.OrderCustPo;
import com.pur.zsms.pmsnmanage.menu.po.MenuPo;
import com.pur.zsms.pmsnmanage.role.vo.RoleVo;
import com.pur.zsms.pmsnmanage.user.dao.IUserDao;
import com.pur.zsms.pmsnmanage.user.dao.IWeiXinDao;
import com.pur.zsms.pmsnmanage.user.po.UnitCommentPo;
import com.pur.zsms.pmsnmanage.user.po.UnitMenuPo;
import com.pur.zsms.pmsnmanage.user.po.UnitPo;
import com.pur.zsms.pmsnmanage.user.po.UserPo;
import com.pur.zsms.pmsnmanage.user.po.UserRolePo;
import com.pur.zsms.pmsnmanage.user.vo.UserVo;
import com.pur.zsms.systemsetting.datadictionary.po.CodeType;

@Repository("weiXinDao")
@Transactional
public class WeiXinDaoImpl extends GenericDao implements IWeiXinDao {
	public void addUnitComment(UnitCommentPo c) throws GenericException {
		this.merge(c);
	}

	@Override
	public List<UnitPo> getAllUnitPo() throws GenericException {
		JpaTemplate template = this.getTemplate();
		StringBuffer ql = new StringBuffer();
		ql.append(" select o ");
		ql.append(" from UnitPo o ");
		List<UnitPo> list = template.find(ql.toString(), null);
		return list;
	}

	@Override
	public List<UnitMenuPo> getAllUnitMenuPo(String unitCode) throws GenericException {
		JpaTemplate template = this.getTemplate();
		StringBuffer ql = new StringBuffer();
		ql.append(" select o ");
		ql.append(" from UnitMenuPo o where o.unitCode ='" + unitCode + "' and o.menuDate ='"
		        + PubFun.getCurrentDate() + "'");
		List<UnitMenuPo> list = template.find(ql.toString(), null);
		return list;
	}

}
